package com.gadgets.busi.bm06.controller;

import com.gadgets.busi.bm06.dto.TradeInfoAddDTO;
import com.gadgets.busi.bm06.dto.TradeLinkInfoAddDTO;
import com.gadgets.busi.bm06.dto.TradeNodeQueryDTO;
import com.gadgets.busi.bm06.fegin.IEupeanTradeInfoController;
import com.gadgets.busi.bm06.pojo.TradeNodeInfo;
import com.gadgets.framework.annotation.RoleAuthCheck;
import com.gadgets.framework.common.dto.HttpBaseResp;
import com.gadgets.framework.common.dto.Pagination;
import com.gadgets.framework.common.exception.GadgetsServiceException;
import com.gadgets.framework.common.util.FeginRequestMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2022-02-27
 */
@RestController
@RequestMapping(value = "/bm06")
public class GadgetsBm06Fork {

    @Autowired
    private IEupeanTradeInfoController eupeanTradeInfoController;

    /**
     * 新增贸易节点信息
     * @param request                       网络请求信息
     * @param response                      网络应答信息
     * @param addDTO                        新增信息
     * @return                              新增结果
     * @throws GadgetsServiceException      异常信息
     */
    @RoleAuthCheck
    @RequestMapping(value = "/addTradeInfo.do")
    @SuppressWarnings("rawtypes")
    public HttpBaseResp addTradeNodeInfo(HttpServletRequest request, HttpServletResponse response, TradeInfoAddDTO addDTO) throws GadgetsServiceException{
        HashMap<String ,Object> requestParam = new HashMap<>();
        FeginRequestMapUtil.parseRequestParam(addDTO,  requestParam);
        return eupeanTradeInfoController.addTradeNodeInfo(requestParam);
    }

    /**
     * 新增贸易节点连接信息
     * @param request                       网络请求信息
     * @param response                      网络应答信息
     * @param tradeNodeLink                 贸易连接信息
     * @return                              新增结果
     * @throws GadgetsServiceException      异常信息
     */
    @RoleAuthCheck
    @RequestMapping(value = "/addTradeLink.do")
    public HttpBaseResp<String> addTradeNodeLink(HttpServletRequest request, HttpServletResponse response, TradeLinkInfoAddDTO tradeNodeLink) throws GadgetsServiceException{
        HashMap<String ,Object> requestParam = new HashMap<>();
        FeginRequestMapUtil.parseRequestParam(tradeNodeLink,  requestParam);
        return eupeanTradeInfoController.addTradeNodeLink(requestParam);
    }

    /**
     * 查询贸易节点信息
     * @param request                   网络请求
     * @param response                  网络应答
     * @param queryDTO                  查询条件
     * @param pagination                分页条件
     * @return                          查询结果
     * @throws GadgetsServiceException  异常信息
     */
    @RoleAuthCheck
    @RequestMapping(value = "/queryTradeNodeInfo.do")
    public HttpBaseResp<TradeNodeInfo> selectNodeInfo(HttpServletRequest request, HttpServletResponse response, TradeNodeQueryDTO queryDTO, Pagination pagination) throws GadgetsServiceException{
        HashMap<String ,Object> requestParam = new HashMap<>();
        FeginRequestMapUtil.parseRequestParam(queryDTO,  requestParam);
        FeginRequestMapUtil.parseRequestParam(pagination,  requestParam);
        return eupeanTradeInfoController.selectNodeInfo(requestParam);
    }

}
